package com.dura.test;

import com.dura.test.client.CacheClient;
import com.dura.test.mapper.ClientBalanceMapper;
import com.dura.test.mapper.ClientTemplateMapper;
import com.dura.test.pojo.ClientBalance;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Map;

/**
 * @version 1.0
 * @Author 振鹏
 * @Date 2025/3/15 18:04
 * @注释
 */
@SpringBootTest
@RunWith(SpringRunner.class)
public class ClientBalanceMapperTest {

    @Autowired
    private ClientBalanceMapper mapper;

    @Autowired
    private CacheClient cacheClient;

    @Test
    public void findByClientId() throws JsonProcessingException {
        ClientBalance balance = mapper.findByClientId(1L);
        System.out.println(balance);
        ObjectMapper objectMapper=new ObjectMapper();
        Map map=objectMapper.readValue(objectMapper.writeValueAsString(balance), Map.class);

        cacheClient.hmset("client_balance:1",map);
    }

}
